<?php

/**
 * Source filter form base class.
 *
 * @package    Coverd
 * @subpackage filter
 * @author     Cameron Ross
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseSourceFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'provider'        => new sfWidgetFormChoice(array('choices' => array('' => '', 'itunes' => 'itunes', 'play' => 'play', 'twitter' => 'twitter', 'facebook' => 'facebook', 'email' => 'email'))),
      'provider_config' => new sfWidgetFormFilterInput(),
      'rating'          => new sfWidgetFormFilterInput(),
      'icon_url'        => new sfWidgetFormFilterInput(),
      'disabled'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'name'            => new sfValidatorPass(array('required' => false)),
      'provider'        => new sfValidatorChoice(array('required' => false, 'choices' => array('itunes' => 'itunes', 'play' => 'play', 'twitter' => 'twitter', 'facebook' => 'facebook', 'email' => 'email'))),
      'provider_config' => new sfValidatorPass(array('required' => false)),
      'rating'          => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'icon_url'        => new sfValidatorPass(array('required' => false)),
      'disabled'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('source_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Source';
  }

  public function getFields()
  {
    return array(
      'id'              => 'Number',
      'name'            => 'Text',
      'provider'        => 'Enum',
      'provider_config' => 'Text',
      'rating'          => 'Number',
      'icon_url'        => 'Text',
      'disabled'        => 'Number',
    );
  }
}
